//Write by oshogbo//vx
//23.07.2011
//http://code.google.com/p/streamobs

import java.util.*;

class Run
{
  public static void main(String[] a)
  {
    SettingsWindow sw = new SettingsWindow();
    sw.loadSettings();
    ArrayList<Channels> channel = sw.createChanelsList();

    Window screen = new Window( channel );
    Tray traiIcon = new Tray(screen, sw);
    new AskWasChanged(screen, channel, sw).start();
  }
}

class AskWasChanged extends Thread
{
  private Window window;
  private ArrayList<Channels> channel;
  private SettingsWindow sw;

  public AskWasChanged(Window s, ArrayList<Channels> channel, SettingsWindow sw)
  {
    window = s;
    this.setDaemon( true );
    this.channel = channel;
    this.sw = sw;
  }

  public void run()
  {
    while( true )
    {
      boolean changed = false;
      for(int i = 0; i < channel.size(); i++)
	if( channel.get(i).wasChanged() == true)
	  changed = true;

      if( !sw.isVisible() && changed == true)
      {
	window.repaint();
	window.setVisible( true );
      }

      try
      {
	this.sleep( 2000 );
      }catch( Exception e)
      {
	
      }
    }
  }
}
